<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
    

    

    



    <meta charset="utf-8">
    
    
    <meta name="sogou_site_verification" content="true">
    
    
    
    <title>HashMap的底层实现 | Lvshen&#39;s Blog | This is My World</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="HashMap,数组">
    <meta name="baidu-site-verification" content="VIVNdSiMZm">
    <meta name="description" content="一、什么是HashMap?​        在讨论HashMap的底层之前，我们必须明白什么是HashMap，HashMap是基于哈希表的Map接口的非同步实现。此实现提供所有可选的映射操作，并允许使用null值和null键。此类不保证映射的顺序，特别是它不保证该顺序恒久不变。 二、HashMap的数据结构​        在java编程语言中，最基本的结构就是两种，一个是数组，另外一个是模拟指针">
<meta name="keywords" content="HashMap,数组">
<meta property="og:type" content="article">
<meta property="og:title" content="HashMap的底层实现">
<meta property="og:url" content="https://lvshen9.gitee.io/2017/08/22/hashmap/index.html">
<meta property="og:site_name" content="Lvshen&#39;s Blog">
<meta property="og:description" content="一、什么是HashMap?​        在讨论HashMap的底层之前，我们必须明白什么是HashMap，HashMap是基于哈希表的Map接口的非同步实现。此实现提供所有可选的映射操作，并允许使用null值和null键。此类不保证映射的顺序，特别是它不保证该顺序恒久不变。 二、HashMap的数据结构​        在java编程语言中，最基本的结构就是两种，一个是数组，另外一个是模拟指针">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://dl.iteye.com/upload/picture/pic/63364/042032ea-6f15-3428-bfb4-b3b1460769a7.jpg">
<meta property="og:updated_time" content="2017-08-22T09:24:26.164Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="HashMap的底层实现">
<meta name="twitter:description" content="一、什么是HashMap?​        在讨论HashMap的底层之前，我们必须明白什么是HashMap，HashMap是基于哈希表的Map接口的非同步实现。此实现提供所有可选的映射操作，并允许使用null值和null键。此类不保证映射的顺序，特别是它不保证该顺序恒久不变。 二、HashMap的数据结构​        在java编程语言中，最基本的结构就是两种，一个是数组，另外一个是模拟指针">
<meta name="twitter:image" content="http://dl.iteye.com/upload/picture/pic/63364/042032ea-6f15-3428-bfb4-b3b1460769a7.jpg">
    
    <link rel="shortcut icon" href="/img/mylogo.jpg">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">我的技术小房间</h5>
          <a href="mailto:https://lvshen9.github.io" title="https://lvshen9.github.io" class="mail">https://lvshen9.github.io</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                Categories
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/about"  >
                <i class="icon icon-lg icon-address-book"></i>
                About
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/collection"  >
                <i class="icon icon-lg icon-apple"></i>
                Collection
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://lvshen9.github.io/" target="_blank" >
                <i class="icon icon-lg icon-wordpress"></i>
                Blog
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/lvshen9" target="_blank" >
                <i class="icon icon-lg icon-github-alt"></i>
                GitHub
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">HashMap的底层实现</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">HashMap的底层实现</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-08-22T09:02:00.000Z" itemprop="datePublished" class="page-time">
  2017-08-22
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/技术/">技术</a></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#一、什么是HashMap"><span class="post-toc-number">1.</span> <span class="post-toc-text">一、什么是HashMap?</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#二、HashMap的数据结构"><span class="post-toc-number">2.</span> <span class="post-toc-text">二、HashMap的数据结构</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#三、HashMap的存取实现"><span class="post-toc-number">3.</span> <span class="post-toc-text">三、HashMap的存取实现</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#四、HashMap的性能参数："><span class="post-toc-number">4.</span> <span class="post-toc-text">四、HashMap的性能参数：</span></a></li></ol>
        </nav>
    </aside>


<article id="post-hashmap"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">HashMap的底层实现</h1>
        <div class="post-meta">
            <time class="post-time" title="2017-08-22 17:02:00" datetime="2017-08-22T09:02:00.000Z"  itemprop="datePublished">2017-08-22</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/技术/">技术</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="一、什么是HashMap"><a href="#一、什么是HashMap" class="headerlink" title="一、什么是HashMap?"></a>一、什么是HashMap?</h2><p>​        在讨论HashMap的底层之前，我们必须明白什么是HashMap，HashMap是基于哈希表的Map接口的非同步实现。此实现提供所有可选的映射操作，并允许使用null值和null键。此类不保证映射的顺序，特别是它不保证该顺序恒久不变。</p>
<h2 id="二、HashMap的数据结构"><a href="#二、HashMap的数据结构" class="headerlink" title="二、HashMap的数据结构"></a>二、HashMap的数据结构</h2><p>​        在java编程语言中，最基本的结构就是两种，一个是数组，另外一个是模拟指针（引用），所有的数据结构都可以用这两个基本结构来构造的，HashMap也不例外。HashMap实际上是一个“链表散列”的数据结构，即数组和链表的结合体。</p>
<p>如图所示:</p>
<a id="more"></a>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="http://dl.iteye.com/upload/picture/pic/63364/042032ea-6f15-3428-bfb4-b3b1460769a7.jpg" alt="img" title>
                </div>
                <div class="image-caption">img</div>
            </figure>
<p>从上图中可以看出，HashMap底层就是一个数组结构，数组中的每一项又是一个链表。当新建一个HashMap的时候，就会初始化一个数组。</p>
<p>分析相关源码:</p>
<ol>
<li><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1</span>. <span class="comment">/** </span></span><br><span class="line"><span class="comment">2.  * The table, resized as necessary. Length MUST Always be a power of two. </span></span><br><span class="line"><span class="comment">3.  */</span>  </span><br><span class="line"><span class="number">4</span>. <span class="keyword">transient</span> Entry[] table;  </span><br><span class="line"><span class="number">5</span>.   </span><br><span class="line"><span class="number">6</span>. <span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">Entry</span>&lt;<span class="title">K</span>,<span class="title">V</span>&gt; <span class="keyword">implements</span> <span class="title">Map</span>.<span class="title">Entry</span>&lt;<span class="title">K</span>,<span class="title">V</span>&gt; </span>&#123;  </span><br><span class="line"><span class="number">7</span>.     <span class="keyword">final</span> K key;  </span><br><span class="line"><span class="number">8</span>.     V value;  </span><br><span class="line"><span class="number">9</span>.     Entry&lt;K,V&gt; next;  </span><br><span class="line"><span class="number">10</span>.     <span class="keyword">final</span> <span class="keyword">int</span> hash;  </span><br><span class="line"><span class="number">11</span>.     ……  </span><br><span class="line"><span class="number">12</span>. &#125;</span><br></pre></td></tr></table></figure>
<p>​</p>
<p>可以看出，Entry就是数组中的元素，每个 Map.Entry 其实就是一个key-value对，它持有一个指向下一个元素的引用，这就构成了链表。</p>
<p>​</p>
</li>
</ol>
<h2 id="三、HashMap的存取实现"><a href="#三、HashMap的存取实现" class="headerlink" title="三、HashMap的存取实现"></a>三、HashMap的存取实现</h2><p>   1) 存储：</p>
<ol>
<li><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1</span>.      <span class="function"><span class="keyword">public</span> V <span class="title">put</span><span class="params">(K key, V value)</span> </span>&#123;  </span><br><span class="line"><span class="number">2</span>.     <span class="comment">// HashMap允许存放null键和null值。  </span></span><br><span class="line"><span class="number">3</span>.     <span class="comment">// 当key为null时，调用putForNullKey方法，将value放置在数组第一个位置。  </span></span><br><span class="line"><span class="number">4</span>.     <span class="keyword">if</span> (key == <span class="keyword">null</span>)  </span><br><span class="line"><span class="number">5</span>.         <span class="keyword">return</span> putForNullKey(value);  </span><br><span class="line"><span class="number">6</span>.     <span class="comment">// 根据key的keyCode重新计算hash值。  </span></span><br><span class="line"><span class="number">7</span>.     <span class="keyword">int</span> hash = hash(key.hashCode());  </span><br><span class="line"><span class="number">8</span>.     <span class="comment">// 搜索指定hash值在对应table中的索引。  </span></span><br><span class="line"><span class="number">9</span>.     <span class="keyword">int</span> i = indexFor(hash, table.length);  </span><br><span class="line"><span class="number">10</span>.     <span class="comment">// 如果 i 索引处的 Entry 不为 null，通过循环不断遍历 e 元素的下一个元素。  </span></span><br><span class="line"><span class="number">11</span>.     <span class="keyword">for</span> (Entry&lt;K,V&gt; e = table[i]; e != <span class="keyword">null</span>; e = e.next) &#123;  </span><br><span class="line"><span class="number">12</span>.         Object k;  </span><br><span class="line"><span class="number">13</span>.         <span class="keyword">if</span> (e.hash == hash &amp;&amp; ((k = e.key) == key || key.equals(k))) &#123;  </span><br><span class="line"><span class="number">14</span>.             V oldValue = e.value;  </span><br><span class="line"><span class="number">15</span>.             e.value = value;  </span><br><span class="line"><span class="number">16</span>.             e.recordAccess(<span class="keyword">this</span>);  </span><br><span class="line"><span class="number">17</span>.             <span class="keyword">return</span> oldValue;  </span><br><span class="line"><span class="number">18</span>.         &#125;  </span><br><span class="line"><span class="number">19</span>.     &#125;  </span><br><span class="line"><span class="number">20</span>.     <span class="comment">// 如果i索引处的Entry为null，表明此处还没有Entry。  </span></span><br><span class="line"><span class="number">21</span>.     modCount++;  </span><br><span class="line"><span class="number">22</span>.     <span class="comment">// 将key、value添加到i索引处。  </span></span><br><span class="line"><span class="number">23</span>.     addEntry(hash, key, value, i);  </span><br><span class="line"><span class="number">24</span>.     <span class="keyword">return</span> <span class="keyword">null</span>;  </span><br><span class="line"><span class="number">25</span>. &#125;</span><br></pre></td></tr></table></figure>
<p>​</p>
<p>​         从上面的源代码中可以看出：当我们往HashMap中put元素的时候，先根据key的hashCode重新计算hash值，根据hash值得到这个元素在数组中的位置（即下标），如果数组该位置上已经存放有其他元素了，那么在这个位置上的元素将以链表的形式存放，新加入的放在链头，最先加入的放在链尾。如果数组该位置上没有元素，就直接将该元素放到此数组中的该位置上。</p>
<p>​        addEntry(hash, key, value, i)方法根据计算出的hash值，将key-value对放在数组table的i索引处。addEntry 是HashMap 提供的一个包访问权限的方法，代码如下：</p>
<ol>
<li><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1</span>. <span class="function"><span class="keyword">void</span> <span class="title">addEntry</span><span class="params">(<span class="keyword">int</span> hash, K key, V value, <span class="keyword">int</span> bucketIndex)</span> </span>&#123;  </span><br><span class="line"><span class="number">2</span>.     <span class="comment">// 获取指定 bucketIndex 索引处的 Entry   </span></span><br><span class="line"><span class="number">3</span>.     Entry&lt;K,V&gt; e = table[bucketIndex];  </span><br><span class="line"><span class="number">4</span>.     <span class="comment">// 将新创建的 Entry 放入 bucketIndex 索引处，并让新的 Entry 指向原来的 Entry  </span></span><br><span class="line"><span class="number">5</span>.     table[bucketIndex] = <span class="keyword">new</span> Entry&lt;K,V&gt;(hash, key, value, e);  </span><br><span class="line"><span class="number">6</span>.     <span class="comment">// 如果 Map 中的 key-value 对的数量超过了极限  </span></span><br><span class="line"><span class="number">7</span>.     <span class="keyword">if</span> (size++ &gt;= threshold)  </span><br><span class="line"><span class="number">8</span>.     <span class="comment">// 把 table 对象的长度扩充到原来的2倍。  </span></span><br><span class="line"><span class="number">9</span>.         resize(<span class="number">2</span> * table.length);  </span><br><span class="line"><span class="number">10</span>. &#125;</span><br></pre></td></tr></table></figure>
<p>​</p>
<p>​          当系统决定存储HashMap中的key-value对时，完全没有考虑Entry中的value，仅仅只是根据key来计算并决定每个Entry的存储位置。我们完全可以把 Map 集合中的 value 当成 key 的附属，当系统决定了 key 的存储位置之后，value 随之保存在那里即可。</p>
<p>​         hash(int h)方法根据key的hashCode重新计算一次散列。此算法加入了高位计算，防止低位不变，高位变化时，造成的hash冲突。</p>
</li>
</ol>
<p>2) 读取：</p>
</li>
<li><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1</span>.      <span class="function"><span class="keyword">public</span> V <span class="title">get</span><span class="params">(Object key)</span> </span>&#123;  </span><br><span class="line"><span class="number">2</span>.     <span class="keyword">if</span> (key == <span class="keyword">null</span>)  </span><br><span class="line"><span class="number">3</span>.         <span class="keyword">return</span> getForNullKey();  </span><br><span class="line"><span class="number">4</span>.     <span class="keyword">int</span> hash = hash(key.hashCode());  </span><br><span class="line"><span class="number">5</span>.     <span class="keyword">for</span> (Entry&lt;K,V&gt; e = table[indexFor(hash, table.length)];  </span><br><span class="line"><span class="number">6</span>.         e != <span class="keyword">null</span>;  </span><br><span class="line"><span class="number">7</span>.         e = e.next) &#123;  </span><br><span class="line"><span class="number">8</span>.         Object k;  </span><br><span class="line"><span class="number">9</span>.         <span class="keyword">if</span> (e.hash == hash &amp;&amp; ((k = e.key) == key || key.equals(k)))  </span><br><span class="line"><span class="number">10</span>.             <span class="keyword">return</span> e.value;  </span><br><span class="line"><span class="number">11</span>.     &#125;  </span><br><span class="line"><span class="number">12</span>.     <span class="keyword">return</span> <span class="keyword">null</span>;  </span><br><span class="line"><span class="number">13</span>. &#125;</span><br></pre></td></tr></table></figure>
<p>​</p>
</li>
</ol>
<p>​         有了上面存储时的hash算法作为基础，理解起来这段代码就很容易了。从上面的源代码中可以看出：从HashMap中get元素时，首先计算key的hashCode，找到数组中对应位置的某一元素，然后通过key的equals方法在对应位置的链表中找到需要的元素。</p>
<p>​        归纳起来简单地说，HashMap 在底层将 key-value 当成一个整体进行处理，这个整体就是一个 Entry 对象。HashMap 底层采用一个 Entry[] 数组来保存所有的 key-value 对，当需要存储一个 Entry 对象时，会根据hash算法来决定其在数组中的存储位置，在根据equals方法决定其在该数组位置上的链表中的存储位置；当需要取出一个Entry时，也会根据hash算法找到其在数组中的存储位置，再根据equals方法从该位置上的链表中取出该Entry。</p>
<h2 id="四、HashMap的性能参数："><a href="#四、HashMap的性能参数：" class="headerlink" title="四、HashMap的性能参数："></a>四、HashMap的性能参数：</h2><p>HashMap 包含如下几个构造器：</p>
<p>HashMap()：构建一个初始容量为 16，负载因子为 0.75 的 HashMap。</p>
<p>HashMap(int initialCapacity)：构建一个初始容量为 initialCapacity，负载因子为 0.75 的 HashMap。</p>
<p>HashMap(int initialCapacity, float loadFactor)：以指定初始容量、指定的负载因子创建一个 HashMap。</p>
<p>HashMap的基础构造器HashMap(int initialCapacity, float loadFactor)带有两个参数，它们是初始容量initialCapacity和加载因子loadFactor。</p>
<p>initialCapacity：HashMap的最大容量，即为底层数组的长度。</p>
<p>loadFactor：负载因子loadFactor定义为：散列表的实际元素数目(n)/ 散列表的容量(m)。</p>
<p>​        负载因子衡量的是一个散列表的空间的使用程度，负载因子越大表示散列表的装填程度越高，反之愈小。对于使用链表法的散列表来说，查找一个元素的平均时间是O(1+a)，因此如果负载因子越大，对空间的利用更充分，然而后果是查找效率的降低；如果负载因子太小，那么散列表的数据将过于稀疏，对空间造成严重浪费。</p>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-08-22T09:24:26.164Z" itemprop="dateUpdated">2017-08-22 17:24:26</time>
</span><br>


        
        原文链接：<a href="/2017/08/22/hashmap/" target="_blank" rel="external">https://lvshen9.gitee.io/2017/08/22/hashmap/</a>
        
    </div>
    
    <footer>
        <a href="https://lvshen9.gitee.io">
            <img src="/img/avatar.jpg" alt="我的技术小房间">
            我的技术小房间
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/HashMap/">HashMap</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/数组/">数组</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://lvshen9.gitee.io/2017/08/22/hashmap/&title=《HashMap的底层实现》 — Lvshen's Blog&pic=https://lvshen9.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://lvshen9.gitee.io/2017/08/22/hashmap/&title=《HashMap的底层实现》 — Lvshen's Blog&source=一、什么是HashMap?​        在讨论HashMap的底层之前，我们必须明白什么是HashMap，HashMap是基于哈希表的Map接口的非同..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://lvshen9.gitee.io/2017/08/22/hashmap/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《HashMap的底层实现》 — Lvshen's Blog&url=https://lvshen9.gitee.io/2017/08/22/hashmap/&via=https://lvshen9.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://lvshen9.gitee.io/2017/08/22/hashmap/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/08/24/sql/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">SQL语句优化问题</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/08/22/my-first-blog/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">搜索引擎选择:Elasticsearch与Solr</h4>
      </a>
    </div>
  
</nav>



    











    <!-- Valine Comments -->
    <div class="comments vcomment" id="comments"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine@latest/dist/Valine.min.js"></script>
    <!-- Valine Comments script -->
    <script>
        var GUEST_INFO = ['nick','mail','link'];
        var guest_info = 'nick,mail,link'.split(',').filter(function(item){
          return GUEST_INFO.indexOf(item) > -1
        });
        new Valine({
            el: '#comments',
            notify: 'false' == 'true',
            verify: 'false' == 'true',
            appId: "dy9kXHwg5jQUlLryQmpjWRlM-gzGzoHsz",
            appKey: "P9Nh39Ol0JbMMiYqNGHEP3ml",
            avatar: "mm",
            placeholder: "Just go go",
            guest_info: guest_info.length == 0 ? GUEST_INFO : guest_info,
            pageSize: "10"
        })
    </script>
    <!-- Valine Comments end -->







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢大爷~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="https://lvshen9.github.io/blog2/pay/weixin.jpg" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check"
                data-wechat="https://lvshen9.github.io/blog2/pay/weixin.jpg" data-alipay="https://lvshen9.github.io/blog2/pay/zhifu.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>我的技术小房间 &copy; 2015 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://lvshen9.gitee.io/2017/08/22/hashmap/&title=《HashMap的底层实现》 — Lvshen's Blog&pic=https://lvshen9.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://lvshen9.gitee.io/2017/08/22/hashmap/&title=《HashMap的底层实现》 — Lvshen's Blog&source=一、什么是HashMap?​        在讨论HashMap的底层之前，我们必须明白什么是HashMap，HashMap是基于哈希表的Map接口的非同..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://lvshen9.gitee.io/2017/08/22/hashmap/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《HashMap的底层实现》 — Lvshen's Blog&url=https://lvshen9.gitee.io/2017/08/22/hashmap/&via=https://lvshen9.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://lvshen9.gitee.io/2017/08/22/hashmap/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=https://lvshen9.gitee.io/2017/08/22/hashmap/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
